g_free (prop_name),
g_free (type_name)));
+ /* We should never come here for these types */
+ g_return_if_fail (type != GDK_TARGET_STRING);
+ g_return_if_fail (type != _text);
+ g_return_if_fail (type != _compound_text);
+ g_return_if_fail (type != _save_targets);
+
if (property == _gdk_selection_property
&& format == 8
&& mode == GDK_PROP_MODE_REPLACE)
{
- if ((type == GDK_TARGET_STRING && GetACP () == 1252) ||
- type == _utf8_string)
+ if (type == _utf8_string)
{
if (!OpenClipboard (GDK_WINDOW_HWND (window)))
{
return;
}
- if (type == _utf8_string)
- {
- /* Check if only ASCII */
- for (i = 0; i < nelements; i++)
- if (data[i] >= 0200)
- break;
- }
- else /* if (type == GDK_TARGET_STRING) */
- {
- /* Check that no 0200..0240 chars present, as they
- * differ between ISO-8859-1 and CP1252.
- */
- for (i = 0; i < nelements; i++)
- if (data[i] >= 0200 && data[i] < 0240)
- break;
- }
nchars = g_utf8_strlen (data, nelements);
+ /* Check if only ASCII */
+ for (i = 0; i < nelements; i++)
+ if (data[i] >= 0200)
+ break;
+
if (i == nelements)
{
- /* If UTF-8 and only ASCII, or if STRING (ISO-8859-1)
- * and system codepage is CP1252, use CF_TEXT and the
- * data as such.
+ /* If UTF-8 and only ASCII, use CF_TEXT and the data as
+ * such.
*/
method = SYSTEM_CODEPAGE;
size = nelements;
const guchar *p = data;
+ /* WordPad on XP, at least, doesn't seem to grok \uc0
+ * -encoded Unicode characters. Oh well, use \uc1 then,
+ * with a question mark as the "ANSI" stand-in for each
+ * non-ASCII Unicode character. (WordPad for XP? This
+ * code path is for Win9x! Yes, but I don't have Win9x,
+ * so I use XP to test, using the G_WIN32_PRETEND_WIN9X
+ * environment variable.)
+ */
method = RICH_TEXT;
- rtf = g_string_new ("{\\rtf1\\uc0 ");
+ rtf = g_string_new ("{\\rtf1\\uc1 ");
while (p < data + nelements)
{
guchar *q;
gint n;
- rtf = g_string_append (rtf, "\\uNNNNN ");
- rtf->len -= 6; /* five digits and a space */
+ rtf = g_string_append (rtf, "\\uNNNNN ?");
+ rtf->len -= 7; /* five digits a space and a question mark */
q = rtf->str + rtf->len;
- n = g_sprintf (q, "%d ", g_utf8_get_char (p));
- g_assert (n <= 6);
+ n = g_sprintf (q, "%d ?", g_utf8_get_char (p));
+ g_assert (n <= 7);
rtf->len += n;
p = g_utf8_next_char (p);
lcidptr = GlobalLock (hlcid);
*lcidptr = lcid;
GlobalUnlock (hlcid);
+ GDK_NOTE (DND, g_print ("... SetClipboardData(CF_LOCALE,%p)\n",
+ hlcid));
if (!SetClipboardData (CF_LOCALE, hlcid))
- WIN32_API_FAILED ("SetClipboardData (CF_LOCALE)"), ok = FALSE;
+ WIN32_API_FAILED ("SetClipboardData(CF_LOCALE)"), ok = FALSE;
}
break;
guchar *utf8ptr = GlobalLock (hutf8);
memmove (utf8ptr, data, nelements);
GlobalUnlock (hutf8);
+ GDK_NOTE (DND, g_print ("... SetClipboardData('UTF8_STRING',%p)\n",
+ hutf8));
if (!SetClipboardData (_cf_utf8_string, hutf8))
- WIN32_API_FAILED ("SetClipboardData (UTF8_STRING)");
+ WIN32_API_FAILED ("SetClipboardData('UTF8_STRING')");
}
break;
}
GlobalUnlock (hdata);
+ GDK_NOTE (DND, g_print ("... SetClipboardData(%s,%p)\n",
+ _gdk_win32_cf_to_string (cf), hdata));
if (ok && !SetClipboardData (cf, hdata))
WIN32_API_FAILED ("SetClipboardData"), ok = FALSE;
}
else
{
+ GDK_NOTE (DND, g_print ("... delayed rendering\n"));
/* Delayed Rendering. We can't assign hdata to the clipboard
* here as type may be "image/png", "image/jpg", etc. In
* this case there's a further conversion afterwards.
{
HWND hwnd;
GdkEvent tmp_event;
- gchar *sel_name;
g_return_val_if_fail (display == _gdk_display, FALSE);
g_return_val_if_fail (selection != GDK_NONE, FALSE);
- GDK_NOTE (DND,
- (sel_name = gdk_atom_name (selection),
- g_print ("gdk_selection_owner_set: %p %#x (%s)\n",
- (owner ? GDK_WINDOW_HWND (owner) : NULL),
- (guint) selection, sel_name),
- g_free (sel_name)));
+#ifdef G_ENABLE_DEBUG
+ {
+ gchar *sel_name;
+
+ GDK_NOTE (DND,
+ (sel_name = gdk_atom_name (selection),
+ g_print ("gdk_selection_owner_set_for_display: %p %#x (%s)\n",
+ (owner ? GDK_WINDOW_HWND (owner) : NULL),
+ (guint) selection, sel_name),
+ g_free (sel_name)));
+ }
+#endif
if (selection != GDK_SELECTION_CLIPBOARD)
{
return FALSE;
_ignore_destroy_clipboard = TRUE;
+ GDK_NOTE (DND, g_print ("... EmptyClipboard()\n"));
if (!API_CALL (EmptyClipboard, ()))
{
_ignore_destroy_clipboard = FALSE;
GdkAtom selection)
{
GdkWindow *window;
- gchar *sel_name;
g_return_val_if_fail (display == _gdk_display, NULL);
g_return_val_if_fail (selection != GDK_NONE, NULL);
window = gdk_window_lookup ((GdkNativeWindow) g_hash_table_lookup (sel_owner_table, selection));
- GDK_NOTE (DND,
- (sel_name = gdk_atom_name (selection),
- g_print ("gdk_selection_owner_get: %#x (%s) = %p\n",
- (guint) selection, sel_name,
- (window ? GDK_WINDOW_HWND (window) : NULL)),
- g_free (sel_name)));
+#ifdef G_ENABLE_DEBUG
+ {
+ gchar *sel_name;
+
+ GDK_NOTE (DND,
+ (sel_name = gdk_atom_name (selection),
+ g_print ("gdk_selection_owner_get: %#x (%s) = %p\n",
+ (guint) selection, sel_name,
+ (window ? GDK_WINDOW_HWND (window) : NULL)),
+ g_free (sel_name)));
+ }
+#endif
return window;
}
{
HGLOBAL hdata;
GdkAtom property = _gdk_selection_property;
- gchar *sel_name, *tgt_name;
- GError *error = NULL;
g_return_if_fail (selection != GDK_NONE);
g_return_if_fail (requestor != NULL);
if (GDK_WINDOW_DESTROYED (requestor))
return;
- GDK_NOTE (DND,
- (sel_name = gdk_atom_name (selection),
- tgt_name = gdk_atom_name (target),
- g_print ("gdk_selection_convert: %p %#x (%s) %#x (%s)\n",
- GDK_WINDOW_HWND (requestor),
- (guint) selection, sel_name,
- (guint) target, tgt_name),
- g_free (sel_name),
- g_free (tgt_name)));
+#ifdef G_ENABLE_DEBUG
+ {
+ gchar *sel_name, *tgt_name;
+
+ GDK_NOTE (DND,
+ (sel_name = gdk_atom_name (selection),
+ tgt_name = gdk_atom_name (target),
+ g_print ("gdk_selection_convert: %p %#x (%s) %#x (%s)\n",
+ GDK_WINDOW_HWND (requestor),
+ (guint) selection, sel_name,
+ (guint) target, tgt_name),
+ g_free (sel_name),
+ g_free (tgt_name)));
+ }
+#endif
if (selection == GDK_SELECTION_CLIPBOARD && target == _targets)
{
data[i++] = _image_bmp;
if (i > 0)
- _gdk_selection_property_store (requestor, GDK_SELECTION_TYPE_ATOM,
- 32, (guchar *) data, i * sizeof (GdkAtom));
+ _gdk_selection_property_store (requestor, GDK_SELECTION_TYPE_ATOM,
+ 32, (guchar *) data, i * sizeof (GdkAtom));
else
property = GDK_NONE;
API_CALL (CloseClipboard, ());
}
- else if (selection == GDK_SELECTION_CLIPBOARD &&
- (target == GDK_TARGET_STRING ||
- target == _utf8_string))
+ else if (selection == GDK_SELECTION_CLIPBOARD && target == _utf8_string)
{
/* Converting the CLIPBOARD selection means he wants the
* contents of the clipboard. Get the clipboard data, and store
p++;
}
- data = g_utf16_to_utf8 (wcs, wclen, NULL, NULL, &error);
+ data = g_utf16_to_utf8 (wcs, wclen, NULL, NULL, NULL);
g_free (wcs);
- if (!data)
- {
- g_error_free (error);
- }
- else
+ if (data)
_gdk_selection_property_store (requestor, target, 8,
data, strlen (data) + 1);
GlobalUnlock (hdata);
}
g_free (wcs);
- data = g_utf16_to_utf8 (wcs2, wclen2, NULL, &length, &error);
+ data = g_utf16_to_utf8 (wcs2, wclen2, NULL, &length, NULL);
g_free (wcs2);
- if (!data)
- g_error_free (error);
- else
+ if (data)
_gdk_selection_property_store (requestor, target, 8,
data, length + 1);
GlobalUnlock (hdata);
API_CALL (CloseClipboard, ());
}
- else if (selection == GDK_SELECTION_CLIPBOARD &&
- target == _image_bmp)
+ else if (selection == GDK_SELECTION_CLIPBOARD && target == _image_bmp)
{
guchar *data;
if (!API_CALL (OpenClipboard, (GDK_WINDOW_HWND (requestor))))
return;
- if ((hdata = GetClipboardData (RegisterClipboardFormat ("image/bmp"))) != NULL)
+ if ((hdata = GetClipboardData (_cf_image_bmp)) != NULL)
{
/* "image/bmp" is the first choice. */
guchar *ptr;
GdkAtom property,
guint32 time)
{
-#ifdef G_ENABLE_DEBUG
- gchar *sel_name, *tgt_name, *prop_name;
-#endif
-
g_return_if_fail (display == _gdk_display);
- GDK_NOTE (DND,
- (sel_name = gdk_atom_name (selection),
- tgt_name = gdk_atom_name (target),
- prop_name = gdk_atom_name (property),
- g_print ("gdk_selection_send_notify_for_display: %#x %#x (%s) %#x (%s) %#x (%s)\n",
- requestor,
- (guint) selection, sel_name,
- (guint) target, tgt_name,
- (guint) property, prop_name),
- g_free (sel_name),
- g_free (tgt_name),
- g_free (prop_name)));
+#ifdef G_ENABLE_DEBUG
+ {
+ gchar *sel_name, *tgt_name, *prop_name;
+
+ GDK_NOTE (DND,
+ (sel_name = gdk_atom_name (selection),
+ tgt_name = gdk_atom_name (target),
+ prop_name = gdk_atom_name (property),
+ g_print ("gdk_selection_send_notify_for_display: %p %#x (%s) %#x (%s) %#x (%s)\n",
+ (gpointer) requestor,
+ (guint) selection, sel_name,
+ (guint) target, tgt_name,
+ (guint) property, prop_name),
+ g_free (sel_name),
+ g_free (tgt_name),
+ g_free (prop_name)));
+ }
+#endif
}
/* It's hard to say whether implementing this actually is of any use
gint length,
gchar ***list)
{
- gchar *enc_name;
gchar *result;
const gchar *charset;
gchar *source_charset;
g_return_val_if_fail (display == _gdk_display, 0);
- GDK_NOTE (DND, (enc_name = gdk_atom_name (encoding),
- g_print ("gdk_text_property_to_text_list_for_display: %s %d %.20s %d\n",
- enc_name, format, text, length),
- g_free (enc_name)));
-
+#ifdef G_ENABLE_DEBUG
+ {
+ gchar *enc_name;
+
+ GDK_NOTE (DND, (enc_name = gdk_atom_name (encoding),
+ g_print ("gdk_text_property_to_text_list_for_display: %s %d %.20s %d\n",
+ enc_name, format, text, length),
+ g_free (enc_name)));
+ }
+#endif
+
if (!list)
return 0;
GSList *convertable_formats, *format;
gboolean has_set_dib = FALSE, has_real_dib = FALSE;
+#ifdef G_ENABLE_DEBUG
+ if (_gdk_debug_flags & GDK_DEBUG_DND)
+ {
+ gchar *sel_name = gdk_atom_name (selection);
+
+ g_print ("gdk_win32_selection_add_targets: %p: %s: ",
+ owner ? GDK_WINDOW_HWND (owner) : NULL,
+ sel_name);
+ g_free (sel_name);
+
+ for (i = 0; i < n_targets; i++)
+ {
+ gchar *tgt_name = gdk_atom_name (targets[i]);
+
+ g_print ("%s ", tgt_name);
+ g_free (tgt_name);
+ }
+ g_print ("\n");
+ }
+#endif
+
if (selection != GDK_SELECTION_CLIPBOARD)
return;
{
gchar *target_name;
- if (targets[i] == _utf8_string)
+ if (targets[i] == _utf8_string ||
+ targets[i] == GDK_TARGET_STRING ||
+ targets[i] == _text ||
+ targets[i] == _compound_text ||
+ targets[i] == _save_targets)
continue;
target_name = gdk_atom_name (targets[i]);
- if (!(formatid = RegisterClipboardFormat (target_name))) {
- WIN32_API_FAILED ("RegisterClipboardFormat");
- API_CALL (CloseClipboard, ());
- g_free (target_name);
- return;
- }
+ if (!(formatid = RegisterClipboardFormat (target_name)))
+ {
+ WIN32_API_FAILED ("RegisterClipboardFormat");
+ API_CALL (CloseClipboard, ());
+ g_free (target_name);
+ return;
+ }
g_hash_table_replace (_format_atom_table, GINT_TO_POINTER (formatid), targets[i]);
+
+ GDK_NOTE (DND, g_print ("... SetClipboardData(%s,NULL)\n",
+ _gdk_win32_cf_to_string (formatid)));
SetClipboardData (formatid, NULL);
/* We should replace the previous image format associated with
g_hash_table_replace (_format_atom_table,
GINT_TO_POINTER (CF_DIB),
targets[i]);
- if (!has_set_dib) {
- SetClipboardData (CF_DIB, NULL);
- has_set_dib = TRUE;
- }
+ if (!has_set_dib)
+ {
+ GDK_NOTE (DND, g_print ("... SetClipboardData(CF_DIB,NULL)\n"));
+ SetClipboardData (CF_DIB, NULL);
+ has_set_dib = TRUE;
+ }
has_real_dib = TRUE;
g_free (target_name);
continue;
g_hash_table_replace (_format_atom_table,
GINT_TO_POINTER (CF_DIB),
targets[i]);
+ GDK_NOTE (DND, g_print ("... SetClipboardData(CF_DIB,NULL)\n"));
SetClipboardData (CF_DIB, NULL);
has_set_dib = TRUE;
break;
ptr = GlobalLock (hdata);
memmove (ptr, ptr + sizeof (BITMAPFILEHEADER), size);
GlobalUnlock (hdata);
- if (!(hdatanew = GlobalReAlloc (hdata, size, 0))) {
- WIN32_API_FAILED ("GlobalReAlloc");
- GlobalFree (hdata); /* the old hdata is not freed if error */
- }
+ if (!(hdatanew = GlobalReAlloc (hdata, size, 0)))
+ {
+ WIN32_API_FAILED ("GlobalReAlloc");
+ GlobalFree (hdata); /* the old hdata is not freed if error */
+ }
return hdatanew;
}